describe("MoveFromListController in SG", function() {

    var controller = null;
    var currentTransfer = null;
    var objE = null;

    beforeEach(function() {
        currentTransfer = App.BaseTransfer.create({
            fromAccount: null,
            currencyCode: null,
            toPayee: false,
            toAccount: App.BaseAccount.create({
                currencyCode: 'SGD'
            }),
            payee: App.BaseAccount.create({
            	accountCurrency: 'SGD'
            })
        });
        objE = new BreezeException({
            errorCode: 123,
            errorMessage: 'error'
        });

        var t_alertCtrl = App.AlertController.create();
        var t_loadingCtrl = App.LoadingController.create();
        App.MoveFromListController.reopen({

            init: function() {
                this.set('controllers.alert', t_alertCtrl);
                this.set('controllers.loading', t_loadingCtrl);

            }

        });

        controller = App.MoveFromListController.create();
    });

    describe("setSourceAccount method test", function() {
        it("setSourceAccount - FromAccount is not cardAccount", function() {
            var account = App.HaveAccount.create({
                currencyCode: 'SGD'
            });

            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(currentTransfer);

            controller.setSourceAccount(account);

            expect(App.getSession().getCurrentTransfer).toHaveBeenCalled();
            expect(currentTransfer.get('fromAccount')).toEqual(account);
            expect(currentTransfer.get('currencyCode')).toEqual(account.currencyCode);
            expect(currentTransfer.get('isCashAdvance')).toBeFalsy();
        });
        it("setSourceAccount - FromAccount is cardAccount", function() {
            var account = App.CardAccount.create({
                currencyCode: 'SGD'
            });

            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(currentTransfer);

            controller.setSourceAccount(account);

            expect(App.getSession().getCurrentTransfer).toHaveBeenCalled();
            expect(currentTransfer.get('fromAccount')).toEqual(account);
            expect(currentTransfer.get('currencyCode')).toEqual(account.currencyCode);
            expect(currentTransfer.get('isCashAdvance')).toBeTruthy();
        });
    });
});